/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

/**
 *
 * @author Pierro
 */
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class CompteEpargne extends CompteBanquaire implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private double taux;
    private String type;

    
    // plusieurs comptes epargne associe a 1 client
    @ManyToOne (cascade=CascadeType.ALL)
    private Client client;
    
    @OneToMany(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
    private Collection<OperationBancaire> listeOperationsCE = new ArrayList();

    public Collection<OperationBancaire> getListeOperationsCE() {
        return listeOperationsCE;
    }
    
    

    public CompteEpargne() {
    }

    public CompteEpargne(double soldeCompte, double taux) {
        super(soldeCompte);
        this.taux = taux;
        this.type = "CptEpargne";
        this.client = client;
        
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Client getClient() {
        return client;
    }

    public double getTaux() {
        return taux;
    }

    public void setTaux(double taux) {
        this.taux = taux;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
    
    
    
    
    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CompteEpargne)) {
            return false;
        }
        CompteEpargne other = (CompteEpargne) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.CompteEpargne[ id=" + id + " ]";
    }
}
